﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Text.RegularExpressions;
using BlogHunter.Manager;

namespace BlogHunter
{
    class BaiduBlog : Blog
    {
        public BaiduBlog()
        {
            //Set Properties.
            AutoSplice = Convert.ToBoolean(ConfigurationSettings.AppSettings["BaiduBlogHomePageAutoSplice"]);
            SpliceRule = ConfigurationSettings.AppSettings["BaiduBlogHomePageSpliceRule"];
            OutPath = ConfigurationSettings.AppSettings["BaiduOutPath"];

            EncodingCharset = ConfigurationSettings.AppSettings["BaiduEncodingCharset"];

            BlogInfoRegex = new Regex(@"<div class=""tit"">([\s]*?)<a href=""([^""]*)"" target=""_blank"">([^<]*)</a></div>([\s]*)<div class=""date"">([\s]*)([^<]*)</div>");
            LinkRegexGroupNum = Convert.ToInt32(ConfigurationSettings.AppSettings["BaiduLinkRegexGroupNum"]);
            TitleRegexGroupNum = Convert.ToInt32(ConfigurationSettings.AppSettings["BaiduTitleRegexGroupNum"]);
            DatetimeRegexGroupNum = Convert.ToInt32(ConfigurationSettings.AppSettings["BaiduDatetimeRegexGroupNum"]);

            NextPageRegex = new Regex(@"<a href=""([^""]*)"">\[下一页\]</a>");
            NextPageRegexGroupNum = Convert.ToInt32(ConfigurationSettings.AppSettings["BaiduNextPageRegexGroupNum"]);

            ChineseDateTimeRegex = new Regex(@"(\S{1,4})年(\S{1,2})月(\S{1,2})日");
            ChineseYearRegexGroupNum = Convert.ToInt32(ConfigurationSettings.AppSettings["BaiduChineseYearRegexGroupNum"]);
            ChineseMonthRegexGroupNum = Convert.ToInt32(ConfigurationSettings.AppSettings["BaiduChineseMonthRegexGroupNum"]);
            ChineseDateRegexGroupNum = Convert.ToInt32(ConfigurationSettings.AppSettings["BaiduChineseDateRegexGroupNum"]);
        }
    }
}
